import { defineStore } from 'pinia'
import { getDepartment, getRoleList, getMenuList } from '@/services/modules/main'
interface mainSate {
  departmentList: any[]
  roleList: any[]
  menuList: any[]
}
const useMainStore = defineStore('main', {
  state: (): mainSate => {
    return {
      departmentList: [],
      roleList: [],
      menuList: []
    }
  },
  actions: {
    // 请求部门列表跟角色列表的数据
    async fetchDepartmentList() {
      const departmentRes = await getDepartment()
      const roleRes = await getRoleList()
      const menuRes = await getMenuList()
      this.departmentList = departmentRes.data.list
      this.roleList = roleRes.data.list
      this.menuList = menuRes.data.list
    }
  }
})

export default useMainStore
